﻿//using Llaans.Models;
//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Web;
//using Layans.Data;
//using Llaans.ViewModels.User;
//using System.Threading.Tasks;
//using System.Collections.Generic;
//using System.Data;
//using System.Data.Entity;
//using System.Data.Entity.Infrastructure;
//using System.Linq;
//using System.Net;
//using System.Net.Http;
//using System.Threading.Tasks;
//using System.Web.Http;
//using System.Web.Http.Description;
//using Layans.Data;
//using LayansAPI.Models;
//namespace Llaans.Controllers.Useres
//{
//    public class Bug : ApiController
//    {
//        LlaansContext db = new LlaansContext();
//        [ResponseType(typeof(UserMassage))]
//        //
//        // GET: /UserMassage/
//        public Task<IHttpActionResult> Index()
//        {
//            return View();
//        }

//        public ActionResult DoCreate()
//        {

//            var post = new UserMassage
//            {
//                Avatar = Avatars,
//                UserName = username,
//                CreationTime = DateTime.Now,
//                Massage = massages,
//            };
//            db.UserMassages.Add(post);
//            db.SaveChanges();

//            return Redirect("/");
//        }

//        public ActionResult ViewMassage(int massageId)
//        {
//            if(!db.UserMassages.Any(x => x.Id == massageId))
//            {
//                return Redirect("/");
//            }

//            var post = db.UserMassages.Where(x => x.Id == massageId)
//                .Select(x => new UserFullMassage
//                {
//                    Id = x.Id,
//                    Avatar = x.Avatar.avatar,
//                    CreationTime = x.CreationTime,
//                    UserName = x.UserName.UserName,
//                }).SingleOrDefault();

//            post.Answer = db.UserMasageAnswers.Where(x => x.Massage.Id == massageId)
//                .Select(y => new UserMassageAnswerViewModel
//                {
//                    Avatar = y.Avatar.avatar,
//                    CreationTime = y.CreationTime,
//                    Massage = y.Answer,
//                    UserName = y.UserName.UserName,
//                });

//            return View(post);
//        }

//        public ActionResult DoAnswer(int userMassageId, string answer)
//        {
//            var userMassage = db.UserMassages.FirstOrDefault(x => x.Id == userMassageId);

//            db.UserMasageAnswers.Add(new UserMassageAnswer 
//            {
//                CreationTime = DateTime.Now,
//                Avatar = Avatars,
//                UserName =  users,
//                Answer = answer,
//            });

//            return Redirect("/");

//        }

//        public ActionResult Vote()
//        {



//            return View();
//        }

//        public Avatar Avatars { get; set; }

//        public LForum.Models.ExternalLoginConfirmationViewModel username { get; set; }

//        public string massages { get; set; }

//        public LForum.Models.ExternalLoginConfirmationViewModel users { get; set; }
//    }
//}